package server.main.utils;

import java.util.*;
import java.util.concurrent.CountDownLatch;

/**
 * @auther MingHsZzz
 * @Date 2023/2/2  15:23
 * @project main
 * @description
 */
public class GenerateNumberByUuid {


   public static int lengthOfLongestSubstring(String s) {
      if(s.equals( ""))
         return 0;
      int max = 0;
      int l= 0,r = 1 ;//左闭右开
      List<Character> list = new ArrayList<>();

      while(r <= s.length()){
         if(list.contains(s.charAt(r - 1))){
            while(s.charAt(l) != s.charAt(r - 1) && l < r){
               list.remove(new Character(s.charAt(l)));
//               System.out.println(l);
               l++;
            }
            l++;

         }else{
            list.add(s.charAt(r - 1));
            if(max < r - l)
               max = r - l;
         }
         r++;
      }
      return max;
   }

   public static void main(String[] args) {
      System.out.println(lengthOfLongestSubstring("abcabcbb"));


   }
}
